home *** CD-ROM | disk | FTP | other *** search
- #ifdef lint
- static char *SCCSid = "%W% (NCSA) %G%";
- #endif
-
- /*
- *
- * Virtual Screen Kernel Emulation Routines
- * (vsem.c)
- *
- * National Center for Supercomputing Applications
- * by Gaige B. Paulsen
- *
- * This file contains the private emulation calls for the NCSA
- * Virtual Screen Kernel.
- *
- * Version Date Notes
- * ------- ------ ---------------------------------------------------
- * 0.01 861102 Initial coding -GBP
- * 0.10 861111 Added/Modified VT emulator -GBP
- * 0.50 861113 First compiled edition -GBP
- * 2.1 871130 NCSA Telnet 2.1 -GBP
- * 2.2 880715 NCSA Telnet 2.2 -GBP
- */
-
- #include <QuickDraw.h>
- #include <Controls.h>
-
- #include "vsdata.h"
- #include "vskeys.h"
- #include "rsmac.h"
- #include "vsinterf.h" /* BYU 2.4.18 */
- #include "vsintern.h"
-
-
- #include "::main:LUU.h" /* Needs these includes. Mostly for LU print routines /Bug */
- #include <PrintTraps.h>
- #include <Fonts.h>
- #include "::main:configrec.h"
- #include "::main:maclook.h"
- #include <OSUtils.h>
- #include <ToolUtils.h>
- #include <Files.h>
- #include <Memory.h>
- #include "vsinterf.h"
- #include "::main:event.h" /* updateCursor() */
- #include <Strings.h>
-
- /* LU originally modified PrintPages, but it's nicer to have a separate
- function, if U ask me. All this to vsem is LU, more or less.. /Bug */
-
- void
- printsleep(); /* The netsleep/ print cancel procedure (menu.c) */
-
- #define ascLF 10
- #define ascFF 12
- #define ascCR 13
- #define PGRECT (*prRecHdl)->prInfo.rPage /* Macro for making the pagerect more accessible */
- #define PAPRECT (*prRecHdl)->rPaper /* Macro for making the paperrect more accessible */
- #define bDevCItoh 1 /* from PrintTraps.h */
-
- extern THPrint prRecHdl; /* our print record handle from menu.c LU /Bug */
- extern SysEnvRec theWorld; /* System Environment record from environ.c LU */
- extern Cursor *normcurs; /* Cursor for non-transfer normal mode from maclook.c LU*/
- extern char
- stupidarray[150]; /* A stupid array for finding the StringWidth (from menu.c) */
-
-
- /*
- * printFile(prPort, columns, refNum) -
- * Prints <file <refNum> on the printer through port <prPort>
- * using <columns>.
- * Note: It expects file position to be 3 chars after what it should print!
- * Should be changed to take parameters with length to print and
- * offset in file, or something. /Bug
- *
- */
- void printFile(prPort, columns, refNum)
- TPPrPort prPort; /* the Printer port */
- int columns;
- short refNum;
- {
- char *start;
- long charlen,count=0L;
- int v, h, scount, lines, pgcount, maxlines;
- FMetricRec info;
- int Fheight, Fwidth;
- unsigned char buf[256]; /* to build a line in from the file */
- unsigned char nextchar; /* next unprocessed char in file */
- int rdy;
- short indent; /* indent to give reasonable left marginal */
- OSErr sts;
- long dummyCount;
- char tmp[100]; /* only for debugging */
-
- putln("in printFile()");
- sprintf(tmp,"prPort:%08x",prPort); putln(tmp);
- sprintf(tmp,"columns:%d",columns); putln(tmp);
- sprintf(tmp,"refNum:%04x",refNum); putln(tmp);
-
- sprintf (tmp,"rPage top,left:%d,%d bot,right:%d,%d",PGRECT.top,PGRECT.left,PGRECT.bottom,PGRECT.right);putln(tmp);
- sprintf (tmp,"rPaper top,left:%d,%d bot,right:%d,%d",PAPRECT.top,PAPRECT.left,PAPRECT.bottom,PAPRECT.right);putln(tmp);
- sprintf (tmp,"rPage iVRes:%d iHRes:%d",(*prRecHdl)->prInfo.iVRes,(*prRecHdl)->prInfo.iHRes);putln(tmp);
-
- indent = ((*prRecHdl)->prInfo.iHRes * 180)/254; /* 1.8 centimeters left margin */
- if (-PAPRECT.left > indent)
- indent = 0;
- else
- indent += PAPRECT.left;
- sprintf(tmp,"indent:%d",indent); putln(tmp);
-
- if ( ((*prRecHdl)->prStl.wDev>>8) == bDevCItoh ) {
- /* Think about this: put def. font in rsrc fork- STR255 */
- TextFont(monaco); /* gives monaco on ImageWriters … */
- v=9;
- }
- else {
- TextFont(courier); /* … and courier on others (incl LW SC) */
- v=14;
- }
-
- do {
- TextSize(v);
- FontMetrics( &info );
- Fheight = FixRound( info.ascent + info.descent + info.leading);
- Fwidth = FixRound( info.widMax);
- Fwidth = CharWidth('W'); /* Re-assign to largest char */
- v--;
- } while ( TextWidth( stupidarray,0,columns+1) > (PGRECT.right - PGRECT.left - indent));
- sprintf (tmp,"Fheight:%d, Fwidth:%d, TextSize:%d",Fheight,Fwidth,v+1); putln (tmp);
-
- if (sts=GetFPos(refNum, &charlen))
- { sprintf(tmp,"GetFPos: ERROR %d",sts); putln(tmp); }
- charlen-=3; /* skip last 3 chars, as they are part of ESC seq */
- if (sts=SetFPos(refNum,(short) fsFromStart,0L)) /* rewind to beginning of file */
- { sprintf(tmp,"SetFPos: ERROR %d",sts); putln(tmp); }
- start = buf;
- dummyCount=1;
- if (sts=FSRead(refNum,&dummyCount,&nextchar)) /* get first char */
- { sprintf(tmp,"FSRead: ERROR %d",sts); putln(tmp); }
-
- sprintf(tmp,"chars to print:%d",charlen); putln(tmp);
-
- h=PGRECT.right - PGRECT.left - indent; /* Get the width */
- v=PGRECT.bottom- PGRECT.top; /* Get the height */
-
- maxlines = v/Fheight-1;
- pgcount = 0;
- while (count<charlen) {
- pgcount++;
- lines = 1;
- PrOpenPage(prPort, 0L); /* Open the Printer Page */
- if (sts=PrError()) { sprintf(tmp,"PrOpenPage: ERROR %d",sts); putln(tmp); }
- (*prRecHdl)->prJob.pIdleProc= (PrIdleProcPtr) printsleep; /* our netsleep */
- sprintf (tmp,"printing page:%d",pgcount); putln(tmp);
-
- /* print from file */
- while (lines <= maxlines && count<charlen) {
- rdy = 0;
- scount = 0;
- while ((count<charlen) && (!rdy)) {
- switch (nextchar) {
- case ascCR:
- rdy=1;
- break;
- case ascLF:
- rdy=1;
- break;
- case ascFF:
- rdy=1;
- break;
- default:
- buf[scount++]=nextchar;
- count++;
- dummyCount=1;
- if (sts=FSRead (refNum,&dummyCount,&nextchar))
- { sprintf(tmp,"FSRead: ERROR %d",sts); putln(tmp); }
- break;
- }
- }
- MoveTo(indent,lines*Fheight);
- if (scount>0)
- DrawText(start, 0, scount);
- if (nextchar==ascLF)
- lines++; /* LF -> new line */
- if (nextchar==ascFF)
- lines = maxlines+1; /* FF -> new page */
- dummyCount=1;
- if (sts=FSRead (refNum,&dummyCount,&nextchar))
- { sprintf(tmp,"FSRead: ERROR %d",sts); putln(tmp); }
- count++;
- }
-
- PrClosePage(prPort); /* Close the Printer page */
- if (sts=PrError()) { sprintf(tmp,"PrClosePage: ERROR %d",sts); putln(tmp); }
- }
-
- putln("leaving printFile()");
- }
-
- void VSprON()
- {
- char tmp[100]; /* only for debugging */
- OSErr sts;
-
- putln ("printer redirection ON");
- VSIw->prredirect = 1;
- VSIw->prbuf = 0x00000000;
- sprintf (VSIw->fname,"NCSA Telnet tempfile #%d",VSIwn);
- (void) c2pstr(VSIw->fname);
- if (sts=Create (VSIw->fname,theWorld.sysVRefNum,'EDIT','TEXT')) {
- SysBeep(1);
- /* Now, if there already is a temporary file, the Create call fails.
- Then it just continues through the script until the end, where it
- doesn't try to close the file (since there was an error condition
- before. That results in the same thing next printout!!!)
- Just try to delete file and do it again. Stupid but robust(?) BUG 910731 */
- sprintf(tmp,"Create : ERROR %d",sts); putln(tmp);
- sts=FSDelete(VSIw->fname,theWorld.sysVRefNum); /* Resultcode? What me worry? */
-
- if (sts=Create (VSIw->fname,theWorld.sysVRefNum,'EDIT','TEXT')) {
- SysBeep(1);
- VSIw->prredirect = 0;
- sprintf(tmp,"Create : ERROR %d",sts); putln(tmp);
- return;
- }
- }
- if (sts=FSOpen (VSIw->fname,theWorld.sysVRefNum,&(VSIw->refNum))) {
- SysBeep(1);
- VSIw->prredirect = 0;
- sprintf(tmp,"FSOpen: ERROR %d",sts); putln(tmp);
- FSDelete (VSIw->fname,theWorld.sysVRefNum);
- return;
- }
- }
-
-
- void VSprOFF()
- {
- Str255 Title;
- TPrStatus prStatus; /* Status record */
- TPPrPort prPort; /* the Printer port */
- OSErr sts;
- GrafPtr savePort;
- char tmp[100]; /* only for debugging */
-
- putln ("printer redirection OFF");
- if (VSIw->prredirect==0) /* no redirection started! */
- return;
- VSIw->prredirect = 0;
- GetPort (&savePort); /* save old port */
-
- if (prRecHdl==0L) { /* Make sure print is inited */
- PrOpen();
- if (sts=PrError()) { sprintf(tmp,"PrOpen: ERROR %d",sts); putln(tmp); }
- prRecHdl=(THPrint)NewHandle((long)sizeof(TPrint));
- PrintDefault(prRecHdl);
- if (sts=PrError()) { sprintf(tmp,"PrintDefault: ERROR %d",sts); putln(tmp); }
- }
-
- GetWTitle ((GrafPtr) RSgetwindow(VSIwn),&Title);
- SetCursor(normcurs);
-
- if (PrJobDialog(prRecHdl)) { /* Cancel the print if FALSE */
- if (sts=PrError()) { sprintf(tmp,"PrJobDialog: ERROR %d",sts); putln(tmp); }
- prPort=PrOpenDoc(prRecHdl,0L,0L);
- if (sts=PrError()) {
- SysBeep(1);
- sprintf(tmp,"PrOpenDoc: ERROR %d",sts); putln(tmp);
- } else {
- printFile (prPort, VSmaxwidth(VSIwn), VSIw->refNum);
- PrCloseDoc(prPort);
- if (sts=PrError()) { sprintf(tmp,"PrCloseDoc: ERROR %d",sts); putln(tmp); }
- if (((*prRecHdl)->prJob.bJDocLoop == bSpoolLoop) && (PrError()==0)) {
- PrPicFile(prRecHdl,0L,0L,0L,&prStatus); /* Spool if necessary… */
- if (sts=PrError()) { sprintf(tmp,"PrPicFile: ERROR %d",sts); putln(tmp); }
- }
- }
- }
- SetPort (savePort); /* restore old port */
- if (sts=FSClose (VSIw->refNum)) {
- SysBeep(1);
- sprintf(tmp,"FSClose: ERROR %d",sts); putln(tmp);
- }
- VSIw->refNum = -1;
- if (sts=FSDelete (VSIw->fname,theWorld.sysVRefNum)) {
- SysBeep(1);
- sprintf(tmp,"FSDelete: ERROR %d",sts); putln(tmp);
- }
- updateCursor(1);
- }
-
-
- #define ENDOFPRT '\033[4i' /* <ESC>[4i (0x1b5b3469) */
-
- void VSpr(pc,pctr)
- int *pctr;
- unsigned char **pc;
- {
- long count; /* number of chars to print to file */
- char *start; /* original start of buffer */
- OSErr sts;
- char tmp[100]; /* only for debugging */
- int rdy; /* true if <ESC>[4i */
-
- count=0;
- start=*pc;
- rdy=0;
-
- while ((*pctr>0) && (!rdy)) {
- VSIw->prbuf=(VSIw->prbuf<<8) + **pc;
- if (VSIw->prbuf==ENDOFPRT) { /* i.e. no more redirection */
- rdy=1;
- count--; /* will be incremented again below */
- }
- count++;
- (*pc)++;
- (*pctr)--;
- }
-
- trbuf7to8 (start,count);
- if (sts=FSWrite(VSIw->refNum,&count,start)) {
- SysBeep(1);
- sprintf(tmp,"FSWrite: ERROR %d",sts); putln(tmp);
- }
- if (rdy || sts)
- VSprOFF();
- }
-
- /* End of LU & Bug strangeness /Bug */
-
-
-
-
- void VSem
- (
- /* Complains about declaring these register when using &ctr, &ctr as
- parameters when calling VSpr. /Bug */
- /* register */ unsigned char *c, /* pointer to character string */
- /* register */ int ctr /* length of character string */
- )
- /* basic routine for placing characters on a virtual screen, and
- interpreting control characters and escape sequences. Simple
- interpretation of controls & escapes is done here, while the
- harder stuff is done by calling VSIxx routines in vsintern.c. */
- {
- register int sx;
- register int escflg; /* state of escape sequence interpretation */
- int insert, attrib, extra, offend;
- char *acurrent, *current, *start;
-
- escflg = VSIw->escflg;
-
- while (ctr > 0)
- {
-
- /* NOTE: Do not capture things that go to the printer! Should it?!? LU /Bug */
- if (VSIw->prredirect) /* printer redirection? LU /Bug */
- VSpr(&c,&ctr); /* if yes, call VSpr */
- /* when we return from VSpr there may be (ctr!=0) … */
- /* … or may not (ctr==0) be chars left in *c to print */
-
- while ((escflg == 0) && (ctr > 0) && (*c < 32))
- {
- switch (*c)
- {
- case 0x1b: /* esc */
- escflg++;
- break;
- case 0x0e: /* shift out */
- if (VSIw->G1)
- VSIw->attrib = VSgraph(VSIw->attrib);
- else
- VSIw->attrib = VSnotgraph(VSIw->attrib);
- VSIw->charset = 1;
- break;
- case 0x0f: /* shift in */
- if (VSIw->G0)
- VSIw->attrib = VSgraph(VSIw->attrib);
- else
- VSIw->attrib = VSnotgraph(VSIw->attrib);
- VSIw->charset = 0;
- break;
- case 0x07: /* bell */
- RSbell(VSIwn);
- break;
- case 0x08: /* backspace */
- VSIw->x--;
- if (VSIw->x < 0)
- /* hit left margin */
- VSIw->x = 0;
- break;
- case 0x0c: /* ff */
- VSIindex();
- break;
- case 0x09: /* ht */ /* Later change for versatile tabbing */
- VSItab();
- VScapture(c,1); /* BYU 2.4.18 */
- break;
- case 0x0a: /* lf */
- VSIindex();
- break;
- case 0x0d: /* cr */
- VSIw->x = 0;
- VScapture(c,1); /* BYU 2.4.18 */
- break;
- case 0x0b: /* vt */
- VSIindex();
- break;
- #ifdef CISB
- case 0x10: /* dle */
- bp_DLE(c, ctr);
- ctr = 0;
- break;
- case 0x05: /* enq */
- bp_ENQ();
- break;
- #endif CISB
- } /* switch */
- c++;
- ctr--;
- } /* while */
- if ((escflg == 0) && (ctr > 0) && (*c & 0x80)) /* BYU 2.4.12 - VT220 starts here */
- { /* BYU 2.4.12 */
- switch (*c) /* BYU 2.4.12 */
- { /* BYU 2.4.12 */
- case 0x84: /* ind */ /* BYU 2.4.12 - same as ESC D */
- VSIindex(); /* BYU 2.4.12 */
- goto ShortCut; /* BYU 2.4.12 */
- case 0x85: /* nel */ /* BYU 2.4.12 - same as ESC E */
- VSIw->x = 0; /* BYU 2.4.12 */
- VSIindex(); /* BYU 2.4.12 */
- goto ShortCut; /* BYU 2.4.12 */
- case 0x88: /* hts */ /* BYU 2.4.12 - same as ESC H */
- VSIw->tabs[VSIw->x] = 'x'; /* BYU 2.4.12 */
- goto ShortCut; /* BYU 2.4.12 */
- case 0x8d: /* ri */ /* BYU 2.4.12 - same as ESC M */
- VSIrindex(); /* BYU 2.4.12 */
- goto ShortCut; /* BYU 2.4.12 */
- case 0x9b: /* csi */ /* BYU 2.4.12 - same as ESC [ */
- VSIapclear(); /* BYU 2.4.12 */
- escflg = 2; /* BYU 2.4.12 */
- break; /* BYU 2.4.12 */
- case 0x86: /* ssa */ /* BYU 2.4.12 - same as ESC F */
- case 0x87: /* esa */ /* BYU 2.4.12 - same as ESC G */
- case 0x8e: /* ss2 */ /* BYU 2.4.12 - same as ESC N */
- case 0x8f: /* ss3 */ /* BYU 2.4.12 - same as ESC O */
- case 0x90: /* dcs */ /* BYU 2.4.12 - same as ESC P */
- case 0x93: /* sts */ /* BYU 2.4.12 - same as ESC S */
- case 0x96: /* spa */ /* BYU 2.4.12 - same as ESC V */
- case 0x97: /* epa */ /* BYU 2.4.12 - same as ESC W */
- case 0x9d: /* osc */ /* BYU 2.4.12 - same as ESC ] */
- case 0x9e: /* pm */ /* BYU 2.4.12 - same as ESC ^ */
- case 0x9f: /* apc */ /* BYU 2.4.12 - same as ESC _ */
- goto ShortCut; /* BYU 2.4.12 */
- } /* switch */ /* BYU 2.4.12 */
- c++; /* BYU 2.4.12 */
- ctr--; /* BYU 2.4.12 */
- } /* if */ /* BYU 2.4.12 */
- while ((ctr > 0) && (escflg == 0) && (*c >= 32))
- {
- /* display printing characters */
- start = &VSIw->linest[VSIw->y]->text[VSIw->x]; /* start of area needing redrawing */
- current = start; /* where to put next char */
- acurrent = &VSIw->attrst[VSIw->y]->text[VSIw->x]; /* where to put corresponding attribute byte */
- attrib = VSIw->attrib; /* current writing attribute */
- insert = VSIw->IRM; /* insert mode (boolean) */
- offend = 0; /* wrapped to next line (boolean) */
- extra = 0; /* overwriting last character of line (boolean) */
- sx = VSIw->x; /* starting column of area needing redrawing */
- if (VSIw->x > VSIw->maxwidth)
- {
- if (VSIw->DECAWM)
- {
- /* wrap to next line */
- VSIw->x = 0;
- VSIindex();
- }
- else
- /* stay at right margin */
- VSIw->x = VSIw->maxwidth;
- current = start = &VSIw->linest[VSIw->y]->text[VSIw->x];
- acurrent = &VSIw->attrst[VSIw->y]->text[VSIw->x];
- sx = VSIw->x;
- } /* if */
- while ((ctr > 0) && (*c >= 32) && (offend == 0))
- {
- /* write characters within a single line */
- if (insert)
- /* make room for the char */
- VSIinschar(1);
-
- trbuf7to8(c,1); /* Translate to Mac 8-bit for the screen. LU /Bug */
-
- /* poke the character and its attribute into the
- screen buffer at the current cursor position */
- *current = *c;
- *acurrent = attrib;
- c++;
- ctr--;
- if (VSIw->x < VSIw->maxwidth)
- {
- /* advance the cursor position */
- acurrent++;
- current++;
- VSIw->x++;
- }
- else
- {
- /* hit right margin */
- if (VSIw->DECAWM)
- {
- /* autowrap to start of next line */
- VSIw->x++;
- offend = 1; /* terminate inner loop */
- }
- else
- {
- /* stay at right margin */
- VSIw->x = VSIw->maxwidth;
- extra = 1; /* cursor position doesn't advance */
- } /* if */
- } /* if */
- } /* while */
- /* update the screen to show what I've done */
- extra += VSIw->x - sx + offend; /* BYU 2.4.18 */
- if (insert)
- VSIinsstring(extra, start); /* BYU 2.4.18 */
- /* actually just decides which RS to use */
- else
- VSIdraw(VSIwn, sx, VSIw->y, VSIw->attrib, extra, start); /* BYU 2.4.18 */
- VScapture((unsigned char *) start, extra); /* BYU 2.4.18 */
- } /* while */
-
- while((ctr > 0) && (escflg == 1))
- { /* basic escape sequence processing */
- switch (*c)
- {
- case 0x08:
- VSIw->x--;
- if (VSIw->x < 0)
- VSIw->x = 0;
- break;
- case '[': /* csi */
- VSIapclear();
- escflg++;
- break;
- case '7':
- VSIsave();
- goto ShortCut; /* BYU 2.4.12 */
- case '8':
- VSIrestore();
- goto ShortCut; /* BYU 2.4.12 */
- case 'c':
- VSIreset();
- break;
- case 'D':
- VSIindex();
- goto ShortCut; /* BYU 2.4.12 */
- case 'E':
- VSIw->x = 0;
- VSIindex();
- goto ShortCut; /* BYU 2.4.12 */
- case 'M':
- VSIrindex();
- goto ShortCut; /* BYU 2.4.12 */
- case '>':
- VSIw->DECPAM = 0;
- goto ShortCut; /* BYU 2.4.12 */
- case '=':
- VSIw->DECPAM = 1;
- goto ShortCut; /* BYU 2.4.12 */
- case 'Z':
- VTsendident();
- goto ShortCut; /* BYU 2.4.12 */
- case ' ': /* BYU 2.4.12 */
- case '*': /* BYU 2.4.12 */
- case '#':
- escflg = 3;
- break;
- case '(':
- escflg = 4;
- break;
- case ')':
- escflg = 5;
- break;
- case 'H':
- VSIw->tabs[VSIw->x] = 'x';
- goto ShortCut; /* BYU 2.4.12 */
- #ifdef CISB
- case 'I':
- bp_ESC_I();
- break;
- #endif CISB
- default:
- goto ShortCut; /* BYU 2.4.12 */
- } /* switch */
- c++;
- ctr--;
- } /* while */
- while ((escflg == 2) && (ctr > 0))
- { /* "control sequence" processing */
- switch (*c)
- {
- case 0x08:
- VSIw->x--;
- if (VSIw->x < 0)
- VSIw->x = 0;
- break;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- /* parse numeric parameter */
- if (VSIw->parms[VSIw->parmptr] < 0)
- VSIw->parms[VSIw->parmptr] = 0;
- VSIw->parms[VSIw->parmptr] = VSIw->parms[VSIw->parmptr] * 10;
- VSIw->parms[VSIw->parmptr] += *c - '0';
- break;
- case '?':
- /* DEC-private control sequence */
- VSIw->parms[VSIw->parmptr++] = -2;
- break;
- case ';':
- /* parameter separator */
- VSIw->parmptr++;
- break;
- case 'A': /* cursor up */
- #if 1 /* BYU */
- if (VSIw->parms[0]<1) VSIw->y--; /* BYU */
- else VSIw->y-=VSIw->parms[0]; /* BYU */
- if ( VSIw->y < 0 ) VSIw->y=0; /* BYU */
- #else /* BYU */
- if (VSIw->y < VSIw->top)
- {
- /* outside scrolling region */
- if (VSIw->parms[0] < 1)
- VSIw->y--;
- else
- VSIw->y -= VSIw->parms[0];
- }
- else
- {
- /* don't leave scrolling region */
- if (VSIw->parms[0] < 1)
- VSIw->y--;
- else
- VSIw->y -= VSIw->parms[0];
- if (VSIw->y < VSIw->top)
- VSIw->y = VSIw->top;
- }
- #endif /* BYU */
- VSIrange();
- goto ShortCut; /* BYU 2.4.12 */
- case 'B': /* cursor down */
- #if 1 /* BYU */
- if (VSIw->parms[0]<1) VSIw->y++; /* BYU */
- else VSIw->y+=VSIw->parms[0]; /* BYU */
- if ( VSIw->y > VSIw->lines ) /* BYU */
- VSIw->y=VSIw->lines; /* BYU */
- #else /* BYU */
- if (VSIw->y > VSIw->bottom)
- {
- /* outside scrolling region */
- if (VSIw->parms[0] < 1)
- VSIw->y++;
- else
- VSIw->y += VSIw->parms[0];
- }
- else
- {
- /* don't leave scrolling region */
- if (VSIw->parms[0] < 1)
- VSIw->y++;
- else
- VSIw->y += VSIw->parms[0];
- if (VSIw->y > VSIw->bottom)
- VSIw->y = VSIw->bottom;
- }
- #endif /* BYU */
- VSIrange();
- goto ShortCut; /* BYU 2.4.12 */
- case 'C': /* cursor right */
- if (VSIw->parms[0] < 1)
- VSIw->x++;
- else
- VSIw->x += VSIw->parms[0];
- VSIrange();
- if (VSIw->x > VSIw->maxwidth)
- VSIw->x = VSIw->maxwidth;
- goto ShortCut; /* BYU 2.4.12 */
- case 'D': /* cursor left */
- if (VSIw->parms[0] < 1)
- VSIw->x--;
- else
- VSIw->x -= VSIw->parms[0];
- VSIrange();
- goto ShortCut; /* BYU 2.4.12 */
- case 'f':
- case 'H':
- /* absolute cursor positioning */
- VSIw->x = VSIw->parms[1] - 1;
- if (VSIw->DECORG)
- /* origin mode -- position relative to top of scrolling region */
- VSIw->y = VSIw->parms[0] - 1 + VSIw->top;
- else
- VSIw->y = VSIw->parms[0] - 1;
- VSIrange();
- goto ShortCut; /* BYU 2.4.12 */
-
- case 'i': /* media copy LU /Bug */
- if (VSIw->parms[VSIw->parmptr]==5) {
- /*c++; ctr--; */
- VSprON(); /* set status and open temp file etc */
- /* chars will be redirected at top of loop … */
- /* … in this procedure */
- }
- escflg = 0;
- break; /* End Printer On LU /Bug */
-
- case 'K':
- /* erase to beginning/end/whole of line */
- switch (VSIw->parms[0])
- {
- case -1:
- case 0:
- VSIeeol();
- break;
- case 1:
- VSIebol();
- break;
- case 2:
- VSIel(-1);
- break;
- default:
- goto ShortCut; /* BYU 2.4.12 */
- } /* switch */
- goto ShortCut; /* BYU 2.4.12 */
- case 'J':
- /* erase to beginning/end/whole of screen */
- switch (VSIw->parms[0])
- {
- case -1:
- case 0:
- VSIeeos();
- break;
- case 1:
- VSIebos();
- break;
- case 2:
- VSIes();
- break;
- default:
- goto ShortCut; /* BYU 2.4.12 */
- } /* switch */
- goto ShortCut; /* BYU 2.4.12 */
- case 'm':
- /* set/clear attributes */
- {
- int temp = 0;
- while (temp <= VSIw->parmptr)
- {
- if (VSIw->parms[temp] < 1)
- VSIw->attrib &= 128; /* turn them all off */
- else if (VSIw->parms[temp] > 20)
- /* turn off the appropriate bit */
- VSIw->attrib &= ~(1 << (VSIw->parms[temp] - 21));
- else
- /* turn on the appropriate bit */
- VSIw->attrib |= 1 << (VSIw->parms[temp] - 1);
- temp++;
- } /* while */
- }
- goto ShortCut; /* BYU 2.4.12 */
- case 'q':
- /* flash dem LEDs. What LEDs? */
- goto ShortCut; /* BYU 2.4.12 */
- case 'c':
- VTsendident();
- goto ShortCut; /* BYU 2.4.12 */
- case 'n':
- switch (VSIw->parms[0])
- {
- case 5:
- VTsendstat();
- break;
- case 6:
- VTsendpos();
- break;
- } /* switch */
- goto ShortCut; /* BYU 2.4.12 */
- case 'L':
- if (VSIw->parms[0] < 1)
- VSIw->parms[0] = 1;
- VSIinslines(VSIw->parms[0], -1);
- goto ShortCut; /* BYU 2.4.12 */
- case 'M':
- if (VSIw->parms[0] < 1)
- VSIw->parms[0] = 1;
- VSIdellines(VSIw->parms[0], -1);
- goto ShortCut; /* BYU 2.4.12 */
- case 'P':
- if (VSIw->parms[0] < 1)
- VSIw->parms[0] = 1;
- VSIdelchars(VSIw->parms[0]);
- goto ShortCut; /* BYU 2.4.12 */
- case 'r':
- /* set scrolling region */
- if (VSIw->parms[0] < 0)
- VSIw->top = 0;
- else
- VSIw->top = VSIw->parms[0] - 1;
- if (VSIw->parms[1] < 0)
- VSIw->bottom = VSIw->lines;
- else
- VSIw->bottom = VSIw->parms[1] - 1;
- if (VSIw->top < 0)
- VSIw->top = 0;
- if (VSIw->top > VSIw->lines - 1)
- VSIw->top = VSIw->lines - 1;
- if (VSIw->bottom < 1)
- VSIw->bottom = VSIw->lines;
- if (VSIw->bottom > VSIw->lines)
- VSIw->bottom = VSIw->lines;
- VSIw->x = 0;
- VSIw->y = 0;
- if (VSIw->DECORG)
- VSIw->y = VSIw->top; /* origin mode relative */
- goto ShortCut; /* BYU 2.4.12 */
- case 'h':
- /* set options */
- VSIsetoption(1);
- goto ShortCut; /* BYU 2.4.12 */
- case 'l':
- /* reset options */
- VSIsetoption(0);
- goto ShortCut; /* BYU 2.4.12 */
- case 'g':
- if (VSIw->parms[0] == 3)
- /* clear all tabs */
- VSItabclear();
- else if (VSIw->parms[0] == 0 || VSIw->parms[0] < 0)
- /* clear tab at current position */
- VSIw->tabs[VSIw->x] = ' ';
- goto ShortCut; /* BYU 2.4.12 */
- case '!': /* BYU 2.4.12 - More private DEC stuff? */
- case '\'': /* BYU 2.4.12 - More private DEC stuff? */
- case '\"': /* BYU 2.4.12 - More private DEC stuff? */
- escflg++; /* BYU 2.4.12 */
- break; /* BYU 2.4.12 */
- default: /* Dang blasted strays... */
- goto ShortCut; /* BYU 2.4.12 */
- } /* switch */
- c++;
- ctr--;
- } /* while */
-
- while ((escflg == 3) && (ctr > 0))
- { /* "#" handling */
- /* no support for double-width and double-height characters yet */
- switch (*c)
- {
- case 0x08:
- VSIw->x--;
- if (VSIw->x < 0)
- VSIw->x = 0;
- break;
- case '8': /* alignment display */
- VTalign();
- goto ShortCut; /* BYU 2.4.12 */
- default:
- goto ShortCut; /* BYU 2.4.12 */
- } /* switch */
- c++;
- ctr--;
- } /* while */
-
- while ((escflg == 4) && (ctr > 0))
- { /* "(" handling (selection of G0 character set) */
- switch (*c)
- {
- case 0x08:
- VSIw->x--;
- if (VSIw->x < 0)
- VSIw->x = 0;
- break;
- case 'A': /* UK */
- case 'B': /* US */
- case '1': /* "soft" */
- VSIw->G0 = 0;
- if (!VSIw->charset)
- VSIw->attrib = VSnotgraph(VSIw->attrib);
- goto ShortCut; /* BYU 2.4.12 */
- case '0': /* DEC special graphics */
- case '2': /* "soft" */
- VSIw->G0 = 1;
- if (!VSIw->charset)
- VSIw->attrib = VSgraph(VSIw->attrib);
- goto ShortCut; /* BYU 2.4.12 */
- default:
- goto ShortCut; /* BYU 2.4.12 */
- } /* switch */
- c++;
- ctr--;
- } /* while */
-
- while ((escflg == 5) && (ctr > 0))
- { /* ")" handling (selection of G1 character set) */
- switch (*c)
- {
- case 0x08:
- VSIw->x--;
- if (VSIw->x < 0)
- VSIw->x = 0;
- break;
- case 'A': /* UK */
- case 'B': /* US */
- case '1': /* "soft" */
- VSIw->G1 = 0;
- if (VSIw->charset)
- VSIw->attrib = VSnotgraph(VSIw->attrib);
- goto ShortCut; /* BYU 2.4.12 */
- case '0': /* DEC special graphics */
- case '2': /* "soft" */
- VSIw->G1 = 1;
- if (VSIw->charset)
- VSIw->attrib = VSgraph(VSIw->attrib);
- goto ShortCut; /* BYU 2.4.12 */
- default:
- goto ShortCut; /* BYU 2.4.12 */
- } /* switch */
- c++;
- ctr--;
- } /* while */
-
- if ((escflg > 2) && (ctr > 0))
- {
- ShortCut: /* BYU 2.4.12 - well, sacrificing style for speed */
- escflg = 0;
- c++;
- ctr--;
- } /* if */
- } /* while (ctr > 0) */
- VSIw->escflg = escflg;
- } /* VSem */
-
-